package com.jlnk.petdemo.viewmodel;

import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;
import com.jlnk.petdemo.repository.PetRepository;

public class PetViewModelFactory implements ViewModelProvider.Factory {
    @Override
    public <T extends ViewModel> T create(Class<T> modelClass) {
        if (modelClass.isAssignableFrom(PetViewModel.class)) {
            PetRepository petRepository = new PetRepository();
            return (T) new PetViewModel(petRepository);
        }
        throw new IllegalArgumentException("Unknown ViewModel class");
    }
}